
#include <string.h>
#include "KmyImagePak.h"
#include <sstream>

KmyImagePak::KmyImagePak()
{
    image = NULL;
    ranges = NULL;
}

KmyImagePak::KmyImagePak(KmyITexture *image, int num, St_Rect *range){
    this->image = image;
    this->img_num = num;

    this->ranges = range;
    if (ranges==NULL){
        ranges = new St_Rect;
        ranges->x = 0;
        ranges->y = 0;
        ranges->w = this->image->width;
        ranges->h = this->image->height;
    }
}

KmyImagePak::~KmyImagePak(){

}

void KmyImagePak::finalize(){
    if (image!=NULL){
        image->finalize();
        delete image;
    }
    delete[] ranges;
}

St_Rect* KmyImagePak::getSubImageClip(int id){
    if (id>=img_num){
        return NULL;
    }
    return &(ranges[id]);
}
